package com.wxapp.system.service.controller.client;

import com.wxapp.common.constant.base.IBaseController;
import com.wxapp.common.constant.pojo.vm.ResultVm;
import com.wxapp.system.api.pojo.vm.city.PCityRelationTreeVm;
import com.wxapp.system.api.pojo.vm.city.PCityRelationVm;
import com.wxapp.system.api.pojo.vo.city.QCitySearchVo;
import com.wxapp.system.service.service.CityService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @author lgl
 * @Description 省市县查询工具类
 * @Datetime 2022/11/10 11:06
 * @Modified By
 */
@RestController
@RequestMapping("/client/city")
@Tag(name = "省市县")
@RequiredArgsConstructor
public class CityClientController extends IBaseController {

    private final CityService cityService;

    @GetMapping("relation")
    @Operation(summary ="获取联动省市县树形菜单")
    public ResultVm<List<PCityRelationVm>> relation(@RequestParam(value = "pid", required = false) String pid) {
        return cityService.relation(pid);
    }

    @PostMapping("relationTree")
    @Operation(summary ="获取联动省市县树形菜单")
    public ResultVm<List<PCityRelationTreeVm>> relationTree(@RequestBody QCitySearchVo qCitySearchVo) {
        return cityService.relationTree(qCitySearchVo);
    }
}
